﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Assessment.aspx.cs" Inherits="House客户端.Assessment" %>

<!DOCTYPE html>
<html>
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>估价页面</title>
    <link href="jquery-easyui-1.5.2/themes/default/easyui.css" rel="stylesheet" />
    <link href="easyui/css/wu.css" rel="stylesheet" />
    <link href="easyui/css/icon.css" rel="stylesheet" />
</head>
<body>
    <input type="hidden" id="ProjectNumber" value="<%=Request["ProjectNumber"] %>" />
    <div class="easyui-panel" fit="true" style="border: none;">
        <div style="margin-left: 30px;" id="ff">
            <table>
                <tr>
                    <td>估价目的：</td>
                    <td style="padding-left: 50px;">
                        <select class="easyui-combobox" style="width: 800px;" id="BasicEvaluation">
                            <option value="买卖">买卖</option>
                            <option value="自住">自住</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>勘察起始日期：</td>
                    <td style="padding-left: 50px;">
                        <input class="easyui-textbox" id="StartTime" type="text" style="width: 800px;" readonly="true" />
                    </td>
                </tr>
                <tr>
                    <td>勘察结束日期：</td>
                    <td style="padding-left: 50px;">
                        <input class="easyui-textbox" id="EndDate" type="text" style="width: 800px;" readonly="true" />
                    </td>
                </tr>
                <tr>
                    <td>价值时点：</td>
                    <td style="padding-left: 50px;">
                        <input class="easyui-textbox" id="Valuepoint" type="text" style="width: 800px;" readonly="true" />
                    </td>
                </tr>
                <tr>
                    <td>建议评估单价(元/㎡)：</td>
                    <td style="padding-left: 50px;">
                        <input class="easyui-textbox" id="Price" type="text" style="width: 800px;" readonly="true" />
                    </td>
                </tr>
                <tr>
                    <td>建筑面积：</td>
                    <td style="padding-left: 50px;">
                        <input class="easyui-textbox" id="Built-uparea" type="text" style="width: 800px;" readonly="true" />
                    </td>
                </tr>
                <tr>
                    <td>估价总值(万元)：</td>
                    <td style="padding-left: 50px;">
                        <input class="easyui-textbox" id="Total" type="text" style="width: 800px;" readonly="true" />
                    </td>
                </tr>
                <tr>
                    <td>Excel估价计算单：</td>
                    <td style="padding-left: 50px;">
                        <input type="file" id="upfile" style="width: 600px;" /><a class="easyui-linkbutton" href="#" id="fileup">导入</a>
                    </td>
                </tr>
                <tr>
                    <td>其他附件（多个文件请使用压缩包）</td>
                    <td style="padding-left: 50px;">
                        <input type="file" id="Enclosure" style="width: 600px;" /><a class="easyui-linkbutton" id="submit" href="#">提交</a>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <script src="jquery-easyui-1.5.2/jquery.min.js"></script>
    <script src="jquery-easyui-1.5.2/jquery.easyui.min.js"></script>
    <script src="jquery-easyui-1.5.2/locale/easyui-lang-zh_CN.js"></script>
    <script src="jquery-easyui-1.5.2/easyloader.js"></script>
    <script src="jquery-easyui-1.5.2/locale/easyui-lang-zh_CN.js"></script>
    <script src="jquery-easyui-1.5.2/Common.js"></script>
    <script>
        //点击导入 将Excel中的信息反填到对应文本框中
        $("#fileup").on('click', function () {
            var AssessmentNumber = $("#AssessmentNumber").val();
            var file = document.getElementById("upfile").files[0];
            if (file == null) {
                $.messager.alert("信息", "请选择要导入的文件！");
                return;
            }
            var reader = new FileReader();
            //将文件以Data URL形式读入页面  
            reader.readAsDataURL(file);
            reader.onload = function (e) {
                var ims = { ProjectNumber: $("#ProjectNumber").val(), ExcelURL: this.result };
                $.post(WebApiURL + "api/Prospecting/ExcelFileUp", ims, function (data) {
                    data = eval(data);
                    for (var i = 0; i < data.length; i++) {
                        $("#StartTime").textbox('setValue', data[i].F1);
                        $("#EndDate").textbox('setValue', data[i].F2);
                        $("#Valuepoint").textbox('setValue', data[i].F3);
                        $("#Price").textbox('setValue', data[i].F4);
                        $("#Built-uparea").textbox('setValue', data[i].F5);
                        $("#Total").textbox('setValue', parseInt(data[i].F4) * parseInt(data[i].F5));
                    }
                });
            }
        });
        $(function () {
            $("#BasicEvaluation").combobox({
                editable: false,//设置下拉框不可编辑
            });
        });
        //点击提交，提交估价信息
        $("#submit").on("click", function () {
            //估价目的
            var Basic_Evaluation = $("#BasicEvaluation").val();
            //估价总值
            var Total = $("#Total").textbox('getValue');
            //建议评估单价
            var Price = $("#Price").textbox('getValue');
            //勘察起始日期
            var StartTime = $("#StartTime").textbox('getValue');
            //勘察结束日期
            var EndDate = $("#EndDate").textbox('getValue');
            //获取项目编号
            var ProjectNumber = $("#ProjectNumber").val();
            //价值时点
            var Valuepoint = $("#Valuepoint").textbox('getValue');
            //建筑面积
            var BuiltUparea = $("#Built-uparea").textbox('getValue');
            //其他附件
            //Excel估价计算单 
            var Basic_Excl = document.getElementById("upfile").files[0];
            var Basic_Enclosure = document.getElementById("Enclosure").files[0];
            if (Basic_Enclosure == undefined) {
                Basic_Enclosure = null;
            }
            var reader = new FileReader();
            var readerExcel = new FileReader();
            //将文件以Data URL形式读入页面  
            reader.readAsDataURL(Basic_Enclosure);
            readerExcel.readAsDataURL(Basic_Excl);
            var dataBasic_Excl;//导入的excel
            readerExcel.onload = function (e) {
                dataBasic_Excl = e.target.result;
            }
            reader = new FileReader();
            reader.readAsDataURL(Basic_Excl);
            reader.onload = function (e) {
                var data = {
                    ProjectNumber: ProjectNumber,
                    Survey_StartTime: StartTime,
                    Survey_EndTime: EndDate,
                    Basic_Evaluation: Basic_Evaluation,
                    Basic_ValueTime: Valuepoint,
                    Basic_UnitPrice: Price,
                    Basic_Acreage: BuiltUparea,
                    Basic_Total: Total,
                    Basic_Excl: dataBasic_Excl,
                    Basic_Enclosure: this.result,
                };
                $.post(WebApiURL + "api/Prospecting/SubmitAssessment", data, function (result) {
                    if (result > 0) {
                        $.messager.alert("提示", "提交成功！");
                        location.href = "AssessmentList.aspx";
                    } else {
                        $.messager.alert("提示", "提交失败！");
                    }
                });
            };
        });
    </script>
</body>
</html>


